<template>
  <div class="login">
    <div class="form-structor">
      <div class="signup">
        <!-- <img src="../assets/images/logo.png" class="img"> -->
        <h2>{{ systemName }}</h2>
        <div class="form-holder">
          <input type="text" v-model="formInline.user" class="input" placeholder="请输入账号" />
          <input type="password" v-model="formInline.password" class="input" placeholder="请输入密码" />
        </div>
        <div class="subtwobut">
          <button class="submit-btn" @click="login">登 录</button>
          <button class="submit-btn" @click="handequ">取 消</button>
        </div>
      </div>
      <div class="accesds">
        <span>接入认证客户端</span>
      </div>
    </div>
    <div class="mindus">
      <span class="el-icon-minus" @click="minimizeWin"></span>
    </div>
    <div class="box_bottom" style="z-index: 999;">
      <div style="float:left; margin-left:10px;font-family: 微软雅黑;">客户端版本 {{ versionNumber }}</div>
      <div style="float:right;margin-right:10px;font-family: 微软雅黑;"> {{ temModename }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "loginAuth",
  data() {
    return {
      systemName: window.systemName,
      versionNumber: '',
      dialdengl: true,
      formInline: {
        user: "",
        password: "",
      },
      loginMode: window.loginMode,
      temModename: window.systemMode == "SINGLE" ? "单机版" : "网络版",
    };
  },
  created() {
    this.$get("/api/v1/getversion").then(res => {
      console.log(res.data)
      this.versionNumber = res.data.version
    })
    var that = this;
    document.onkeydown = function (e) {
      var key = window.event.keyCode;
      if (that.$route.name === "loginAuth") {
        if (key == 13) {
          that.login();
        }
      }
    };
  },
  methods: {
    login() {
      let userNameValue = this.formInline.user;
      let pinValue = this.formInline.password;
      if (userNameValue === "") {
        this.$message({
          message: "账号不能为空！",
          type: "warning",
        });
        return false;
      }
      if (pinValue === "") {
        this.$message({
          message: "密码不能为空！",
          type: "warning",
        });
        return false;
      }
      let data = {
        user: userNameValue, // 认证用户
        password: pinValue, //认证密码
      };
      if (this.loginMode == "DEBUG") {
        this.$router.push("/home");
      } else {
        this.$postForJson("/jrkz/auth/authlogin", data).then((res) => {
          if (res.data.errorcode == "0") {
            this.$message({
              message: "认证通过！",
              type: "success",
            });
          } else {
            this.$message({
              message: "认证失败，" + res.data.errmsg,
              type: "warning",
            });
          }
          this.$router.push("/home");
        });
      }
    },
    handequ() {
      this.$router.push("/home");
    },
    // 主进程发送缩小
    minimizeWin() {
      window.electron.ipcRenderer.send("window-min");
    },
  },
};
</script>

<style scoped>
.login {
  overflow: hidden;
  background-color: white;
  /* padding: 40px 30px 30px 30px; */
  /* border-radius: 10px; */
  position: relative;
  /* top: 50%;
  left: 50%;
  width: 400px; */
  width: 100%;
  height: 100vh;
  /* transform: translate(-50%, -50%); */
  transition: transform 300ms, box-shadow 300ms;
  box-shadow: 5px 10px 10px rgba(2, 128, 144, 0.2);
}

.login::before,
.login::after {
  content: "";
  position: absolute;
  width: 700px;
  height: 700px;
  border-top-left-radius: 40%;
  border-top-right-radius: 45%;
  border-bottom-left-radius: 35%;
  border-bottom-right-radius: 40%;
  z-index: 10;
}

.login::after {
  width: 900px;
  height: 900px;
}

.login::before {
  right: -35%;
  top: -85%;
  background-color: #44b979;
  animation: wawes 6s infinite linear;
}

.login::after {
  left: -50%;
  bottom: -115%;
  background-color: #44b979;
  animation: wawes 7s infinite;
}

@keyframes wawes {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(360deg);
  }
}

.bnesuts {
  width: 70%;
  height: 50%;
  border-radius: 15px;
  float: left;
  margin-top: 15%;
  margin-left: 15%;
  background-image: url(../assets/images/2.jpg);
}

.dengshus {
  width: 50%;
  height: 80%;
  float: right;
  display: flex;
  flex-direction: column;
  margin-top: 5%;
  /* background: #4581b5; */
  /* border-radius: 14px;
  box-shadow: 0px 0px 10px 6px rgba(0, 0, 0, 0.1);
  opacity: 1; */
  /* align-items: center; */
}

h2 {
  margin-left: 45px;
  margin-bottom: 14px;
  /* margin-top: 2%; */
  font-size: 25px;
  color: #484848;
  /* color: #fff; */
}

.img {
  float: left;
  width: 40px;
}

.box_logins {
  width: 100%;
  height: 100%;
  /* background: #DF0712; */
  /* background-image: linear-gradient(-245deg, transparent 15%, #44B979 50%, #32A666 100%); */
}

:deep(.el-form-item__content) {
  width: 68%;
}

:deep(.el-dialog) {
  height: 100%;
  margin-top: 0 !important;
  margin: 0 auto;
}

:deep(.el-form) {
  display: flex;
  flex-direction: column;
}

.dialog-footer {
  margin-left: 90px;
  /* float: right; */
}

.demo-ruleForm {
  margin-bottom: 10px;
}

.form-structor {
  background-color: #222;
  border-radius: 15px;
  height: 350px;
  width: 425px;
  position: relative;
  overflow: hidden;
  left: 30%;
  top: 20%;
}

.form-structor::after {
  content: "";
  opacity: 0.8;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 500px;
  background-color: #44b979;
  background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
  background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%);
}

.form-structor .signup {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  width: 65%;
  z-index: 5;
  -webkit-transition: all 0.3s ease;
}

.form-structor .signup.slide-up .form-title span {
  margin-right: 5px;
  opacity: 1;
  visibility: visible;
  -webkit-transition: all 0.3s ease;
}

.form-structor .signup .form-title {
  color: #fff;
  font-size: 1.7em;
  text-align: center;
}

.form-structor .signup .form-title span {
  color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  -webkit-transition: all 0.3s ease;
}

.form-structor .signup .form-holder {
  border-radius: 15px;
  background-color: #fff;
  overflow: hidden;
  margin-top: 50px;
  opacity: 1;
  visibility: visible;
  -webkit-transition: all 0.3s ease;
}

.form-structor .signup .form-holder .input {
  border: 0;
  outline: none;
  box-shadow: none;
  display: block;
  height: 30px;
  line-height: 30px;
  padding: 8px 15px;
  border-bottom: 1px solid #eee;
  width: 100%;
  font-size: 12px;
}

.form-structor .signup .form-holder .input:last-child {
  border-bottom: 0;
}

.form-structor .signup .form-holder .input::-webkit-input-placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.form-structor .signup .submit-btn {
  background-color: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 0;
  border-radius: 15px;
  display: block;
  margin: 15px auto;
  padding: 15px 45px;
  width: 48%;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  opacity: 1;
  visibility: visible;
  -webkit-transition: all 0.3s ease;
}

.form-structor .signup .submit-btn:hover {
  transition: all 0.3s ease;
  background-color: rgba(0, 0, 0, 0.6);
}

.accesds {
  position: absolute;
  top: 78px;
  left: 120px;
  color: #fff;
  z-index: 999;
  font-size: 14px;
}

.subtwobut {
  display: flex;
}

.mindus {
  position: absolute;
  top: 2px;
  right: 8px;
  z-index: 999;
  cursor: pointer;
  font-size: 22px;
  color: #fff;
}
</style>